unit imp_EtqAlbatroz_Div;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Formulario_Padrao_Rel, RDprint, ExtCtrls, StdCtrls, CheckLst,
  ComCtrls, TFlatButtonUnit, Buttons, Spin;

type
  TfrmImpr_EtqAlb_Div = class(TFrmPad_Rel)
    edLin1: TEdit;
    edLin2: TEdit;
    edLin3: TEdit;
    Label1: TLabel;
    edQtde: TSpinEdit;
    Label2: TLabel;
    rgTipo: TRadioGroup;
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bimprimirClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmImpr_EtqAlb_Div: TfrmImpr_EtqAlb_Div;

implementation

uses clsParametros, Biblio;

var
 Parametros: TParametros;

{$R *.dfm}

procedure TfrmImpr_EtqAlb_Div.FormActivate(Sender: TObject);
begin
  inherited;
 edLin1.Clear;
 edLin2.Clear;
 edLin3.Clear;
 edQtde.Value:= 1;
 edLin1.SetFocus;
end;

procedure TfrmImpr_EtqAlb_Div.FormCreate(Sender: TObject);
begin
  inherited;
 Parametros:= TParametros.Create;
end;

procedure TfrmImpr_EtqAlb_Div.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
 Parametros.Free;
end;

procedure TfrmImpr_EtqAlb_Div.bimprimirClick(Sender: TObject);
var
 PortaImpr: String;
 w,i: Integer;
 F,Arq: TextFile;
begin
  inherited;
 Parametros.Recuperar('1');
 AssignFile(Arq,Parametros.Repos_personal+'Zebra.imp');
 Reset(Arq);
 Readln(Arq,PortaImpr);
 CloseFile(Arq);
 PortaImpr:= AllTrim(copy(PortaImpr,2,5));
 //PortaImpr:= 'C:\EPL2.txt';
 ASSIGNFILE(F,PortaImpr);
 w:= iv(edQtde.Value) div 2;
 for i:= 1 to w do begin
  Rewrite(F);
  Writeln(F,'N');
  if rgTipo.ItemIndex = 0 then begin
   //                  R F m m
   Writeln(F,'A260,020,1,2,6,6,N,"'+edLin1.Text+'"');
   Writeln(F,'A165,020,1,2,6,6,N,"'+edLin2.Text+'"');
   Writeln(F,'A070,020,1,2,6,6,N,"'+edLin3.Text+'"');
   Writeln(F,'A620,020,1,2,6,6,N,"'+edLin1.Text+'"');
   Writeln(F,'A520,020,1,2,6,6,N,"'+edLin2.Text+'"');
   Writeln(F,'A430,020,1,2,6,6,N,"'+edLin3.Text+'"');
  end else begin
   Writeln(F,'A370,020,1,2,5,5,N,"'+edLin1.Text+'"');
   Writeln(F,'A275,020,1,2,5,5,N,"'+edLin2.Text+'"');
   Writeln(F,'A180,020,1,2,5,5,N,"'+edLin3.Text+'"');
   Writeln(F,'A730,020,1,2,5,5,N,"'+edLin1.Text+'"');
   Writeln(F,'A630,020,1,2,5,5,N,"'+edLin2.Text+'"');
   Writeln(F,'A540,020,1,2,5,5,N,"'+edLin3.Text+'"');
  end;
  Writeln(F,'P1'+chr(10)+chr(13));
  CloseFile(F);
 end;

 w:= iv(edQtde.Value) mod 2;
 if w <> 0 then begin
  Rewrite(F);
  Writeln(F,'N');
  if rgTipo.ItemIndex = 0 then begin
   Writeln(F,'A260,020,1,2,6,6,N,"'+edLin1.Text+'"');
   Writeln(F,'A165,020,1,2,6,6,N,"'+edLin2.Text+'"');
   Writeln(F,'A070,020,1,2,6,6,N,"'+edLin3.Text+'"');
  end else begin
   Writeln(F,'A370,020,1,2,5,5,N,"'+edLin1.Text+'"');
   Writeln(F,'A275,020,1,2,5,5,N,"'+edLin2.Text+'"');
   Writeln(F,'A180,020,1,2,5,5,N,"'+edLin3.Text+'"');
  end;
  Writeln(F,'P1'+chr(10));
  CloseFile(F);
 end;

end;

end.
